package com.hefeng.wx.controller;

import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hefeng.common.core.web.domain.AjaxResult;
import com.hefeng.wx.controller.entity.ParamEntity;
import com.hefeng.wx.domain.WxUserOrder;
import com.hefeng.wx.service.WxUserOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


 /**
 * 设备工单信息表;(wx_device_order)表控制层
 * @author : http://www.chiner.pro
 * @date : 2022-9-19
 */
@Api(tags = "用户工单信息表对象功能接口")
@RestController
@RequestMapping("/resident/wxDeviceOrder")
public class WxUserOrderController{
    @Autowired
    private WxUserOrderService wxUserOrderService;
    /**
     * 方法说明:获取工单分页记录
     * @param paramEntity
     * @return null
     * @Author: huzh
     * @Date: 2022/9/20
     */
     @RequestMapping(value = "/getOrderPage",produces = "application/json;charset=UTF-8")
     @ApiOperation("获取工单分页列表")
     public AjaxResult getOrderPage(@RequestBody ParamEntity paramEntity){
         Map<String,Object> dataMap=new HashMap<>();
         WxUserOrder wxUserOrder =new WxUserOrder();
         wxUserOrder.setUserId(Long.parseLong(paramEntity.getUserId()));
         Page<WxUserOrder> page=wxUserOrderService.getOrderPage(wxUserOrder,paramEntity.getPage(), paramEntity.getPageSize());
         return AjaxResult.success("获取工单列表成功！",page);
     }

     @RequestMapping(value = "/seveOrder",produces = "application/json;charset=UTF-8")
     @ApiOperation("保存工单信息")
     public AjaxResult seveOrder(@RequestBody WxUserOrder wxUserOrder){
         Map<String,Object> dataMap=new HashMap<>();
         dataMap=wxUserOrderService.insert(wxUserOrder);
         if(!dataMap.get("make").equals(true)){
             return AjaxResult.error(501,dataMap.get("msg").toString());
         }
         return AjaxResult.success("保存工单成功！",dataMap);
     }
}